package com.ziyun.pop.modules.mercharReport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ziyun.pop.modules.mercharReport.dao.ReportStoreStockMaterialDao;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreStockMaterialEntity;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreStockMaterialVo;
import com.ziyun.pop.modules.mercharReport.service.ReportStoreStockMaterialService;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;



@Service("reportStoreStockMaterialService")
public class ReportStoreStockMaterialServiceImpl extends ServiceImpl<ReportStoreStockMaterialDao, ReportStoreStockMaterialEntity> implements ReportStoreStockMaterialService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ReportStoreStockMaterialEntity> page = (Page<ReportStoreStockMaterialEntity>) this.page(
                new Query<ReportStoreStockMaterialEntity>(params).getPage(),
                new QueryWrapper<ReportStoreStockMaterialEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R list(Map<String, Object> params) {
        Page<ReportStoreStockMaterialVo> page = new Page<>();
        page.setCurrent(Integer.valueOf(params.get("page").toString()));
        page.setSize(Integer.valueOf(params.get("limit").toString()));
        List<ReportStoreStockMaterialVo> list = this.baseMapper.list(page, params);
        page.setRecords(list);
        PageUtils pageUtils = new PageUtils(page);
        // 存放枚举类到userdata
        Map<String, List> mapEnum = new HashMap<>();
        return R.ok().put("page", pageUtils).put("userData", mapEnum);
    }

    @Override
    public List<ReportStoreStockMaterialVo> exportExcel(Map<String, Object> params) {
        return this.baseMapper.exportExcel(params);
    }
}
